Overview of ld, the GNU linker

Contents|Index|Next
Overview of ld, the GNU linker

ld combines a number of object and archive files, relocates their data and ties up symbol references. Usually the last step in compiling a program is to run ld.

For specific discussion on the linker, see the following documentation.

- Invocation

- Command line options
- Environment variables

- Linker scripts

- Basic linker script concepts
- Linker script format
- Simple linker script example
- Simple linker script commands
- Setting the entry point
- Commands dealing with files
- Commands dealing with object file formats
- Other linker script commands
- Assigning values to symbols
- Simple assignments
- `PROVIDE` command
- `SECTIONS` command
- Output section description
- Output section name
- Output section address
- Input section description
- Input section basics
- Input section wildcard patterns
- Input section for common symbols
- Input section example
- Output section data
- Output section keywords
- Output section discarding
- Output section attributes
- Output section type
- Output section LMA
- Output section region
- Output section `phdr`
- Output section fill
- Overlay description
- `MEMORY` command
- `PHDRS` command
- `VERSION` command
- Expressions in linker scripts
- Constants
- Symbol names
- The location counter
- Operators
- Evaluation
- The section of an expression
- Builtin functions

- Machine dependent features
- BFD
- MRI compatible script files

ld accepts Linker Command Language files written in a superset of AT&T’s Link Editor Command Language syntax, to provide explicit and total control over the linking process.

This version of ld uses the general purpose BFD libraries to operate on object files. This allows ld to read, combine, and write object files in many different formats—for example, COFF or a.out. Different formats may be linked together to produce any available kind of object file. See BFD for more information.

Aside from its flexibility, the GNU linker is more helpful than other linkers in providing diagnostic information. Many linkers abandon execution immediately upon encountering an error; whenever possible, ld continues executing, allowing you to identify other errors (or, in some cases, to get an output file in spite of the error).

Top|Contents|Index|Next